package com.micro.modual.service.impl;

import com.micro.common.MicroResponseCode;
import com.micro.core.exception.BizException;
import com.micro.core.frame.service.impl.AbstractBasicsServiceImpl;
import com.micro.core.resp.RespJson;
import com.micro.modual.entity.UserLevel;
import com.micro.modual.extension.UserLevelExtension;
import com.micro.modual.mapper.UserLevelMapper;
import com.micro.modual.model.bo.userlevel.UserLevelBO;
import com.micro.modual.service.UserLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
*  <h1>用户等级表  实现</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:09
 */
@Service("userLevelService")
public class UserLevelServiceImpl extends AbstractBasicsServiceImpl<UserLevel,Long> implements UserLevelService {

    @Autowired
    private UserLevelMapper userLevelMapper;

    /**
     * <h2>新增用户等级表详情</h2>
     * @param userLevelBO {@link UserLevelBO} 用户等级表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson addUserLevel(UserLevelBO userLevelBO) {
        UserLevel userLevel = UserLevelExtension.converAddUserLevel(userLevelBO);
        userLevelMapper.insertSelective(userLevel);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(), MicroResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * <h2>修改用户等级表详情</h2>
     * @param userLevelBO  {@link UserLevelBO} 用户等级表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson editUserLevel(UserLevelBO userLevelBO) {
        UserLevel userLevel = UserLevelExtension.converEditUserLevel(userLevelBO);
        userLevelMapper.updateByPrimaryKeySelective(userLevel);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());

    }

    /**
     * <h2>根据主键编号删除用户等级表信息</h2>
     * @param id  用户等级表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */

    @Override
    public RespJson deleteUserLevel(Long id) {
        userLevelMapper.deleteByPrimaryKey(id);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());
    }

}
